Page({
    data: {
        phone: '',
        messageCode:'',
        sendCodeText:'点击发送验证码',
        codeTimer:10
    },

// 获取输入账号
    phoneInput :function (e) {
        this.setData({
            phone:e.detail.value
        })
    },

// 获取输入密码
    passwordInput :function (e) {
        this.setData({
          messageCode:e.detail.value
        })
    },

// 登录
    login: function () {
      if (this.data.phone.length == 0 || this.data.messageCode.length == 0){
            wx.showToast({
                title: '用户名和密码不能为空',
                icon: 'loading',
                duration: 2000
            })
        }else {
            // 这里修改成跳转的页面
            wx.showToast({
                title: '登录成功',
                icon: 'success',
                duration: 2000
            })
            wx.navigateBack({
              delta: 1
            })
        }
    },
    sendMobileCode:function() {
        // 这里修改成跳转的页面
      if (this.data.phone.length == 11){
        
        this.timer=setInterval(() => {
          this.setData({
            sendCodeText: this.data.codeTimer + "秒后重发",
            codeTimer:this.data.codeTimer-1
          })
        }, 1000) 
          wx.showToast({
            title: '验证码已发送',
            icon: 'success',
            duration: 2000
          })
      }else{
        wx.showToast({
          title: '手机号码不正确',
          icon: 'loading',
          duration: 2000
        })
      }
        
    }
})